cmake_minimum_required(VERSION 2.8.4)

STRING(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} )
MESSAGE("current project: " ${CURRENT_FOLDER})

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)

cmake_host_system_information(RESULT arch_value QUERY OS_PLATFORM)
message(STATUS "architecture: " ${arch_value})

if(NOT "${arch_value}" STREQUAL "armv7l")
	include ($ENV{HOME}/configs/cross.cmake)
endif()

#若要使用${CMAKE_SYSROOT}变量，project必须要在set(CMAKE_TOOLCHAIN_FILE "${HOST_DIR}/share/buildroot/toolchainfile.cmake")后面设置
project(${CURRENT_FOLDER})
add_definitions(-Wall -Wpointer-arith)
# use c++ 11
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall")


# ======================== easyeai_api =========================
set(toolkit_root ${CMAKE_CURRENT_SOURCE_DIR}/../easyeai-api)
# -I
set(api_inc
   ${toolkit_root}/algorithm_api/face_detect
   ${toolkit_root}/algorithm_api/face_landmark98
   ${toolkit_root}/algorithm_api/smoke_detect
   ${toolkit_root}/algorithm_api/phonecall_detect
   ${toolkit_root}/common_api/system_opt
   ${toolkit_root}/peripheral_api/camera
   ${toolkit_root}/peripheral_api/display
   )
# -L
link_directories(${toolkit_root}/algorithm_api/face_detect)
link_directories(${toolkit_root}/algorithm_api/face_landmark98)
link_directories(${toolkit_root}/algorithm_api/smoke_detect)
link_directories(${toolkit_root}/algorithm_api/phonecall_detect)
link_directories(${toolkit_root}/common_api/system_opt)
link_directories(${toolkit_root}/peripheral_api/camera)
link_directories(${toolkit_root}/peripheral_api/display)
# -l
LINK_LIBRARIES( system_opt pthread )
LINK_LIBRARIES( display easymedia rga )
LINK_LIBRARIES( camera easymedia rga rkaiq)
LINK_LIBRARIES( phonecall_detect smoke_detect face_landmark98 face_detect rknn_api )
# ======================== easyeai_api =========================


# ========================== custom ============================
# solution project
find_package(OpenCV REQUIRED)
# -I
set(custom_inc
   ${OpenCV_INCLUDE_DIRS}
   ${PROJECT_SOURCE_DIR}/include
)
# -L
link_directories(${PROJECT_SOURCE_DIR}/libs)
# -l
set(custom_libs
   ${OpenCV_LIBS}
)
# source code
aux_source_directory(./src dir_srcs)
# ========================== custom ============================

#--------------------------
# execute file
#--------------------------
add_executable(${CURRENT_FOLDER} ${dir_srcs})
target_include_directories(${CURRENT_FOLDER} PRIVATE ${api_inc} ${custom_inc})
target_link_libraries(${CURRENT_FOLDER} ${custom_libs})

